package com.cm.caseManagement.controller;

import com.cm.caseManagement.annotation.Log;
import com.cm.caseManagement.core.controller.BaseController;
import com.cm.caseManagement.core.domain.AjaxResult;
import com.cm.caseManagement.core.page.TableDataInfo;
import com.cm.caseManagement.pojo.entity.CmMoveRecord;
import com.cm.caseManagement.pojo.enums.BusinessType;
import com.cm.caseManagement.service.ICmMoveRecordService;
import com.cm.caseManagement.utils.poi.ExcelUtil;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 移交记录Controller
 *
 * @author ruoyi
 * @date 2025-10-05
 */
@RestController
@RequestMapping("/caseManagement/moveRecord")
public class CmMoveRecordController extends BaseController
{
    @Autowired
    private ICmMoveRecordService cmMoveRecordService;

    /**
     * 查询移交记录列表
     */
    @PreAuthorize("@ss.hasPermi('caseManagement:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(CmMoveRecord cmMoveRecord)
    {
        startPage();
        List<CmMoveRecord> list = cmMoveRecordService.selectCmMoveRecordList(cmMoveRecord);
        return getDataTable(list);
    }

    /**
     * 导出移交记录列表
     */
    @PreAuthorize("@ss.hasPermi('caseManagement:record:export')")
    @Log(title = "移交记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmMoveRecord cmMoveRecord)
    {
        List<CmMoveRecord> list = cmMoveRecordService.selectCmMoveRecordList(cmMoveRecord);
        ExcelUtil<CmMoveRecord> util = new ExcelUtil<CmMoveRecord>(CmMoveRecord.class);
        util.exportExcel(response, list, "移交记录数据");
    }

    /**
     * 获取移交记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('caseManagement:record:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cmMoveRecordService.selectCmMoveRecordById(id));
    }

    /**
     * 新增移交记录
     */
    @PreAuthorize("@ss.hasPermi('caseManagement:record:add')")
    @Log(title = "移交记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmMoveRecord cmMoveRecord)
    {
        return toAjax(cmMoveRecordService.insertCmMoveRecord(cmMoveRecord));
    }

    /**
     * 修改移交记录
     */
    @PreAuthorize("@ss.hasPermi('caseManagement:record:edit')")
    @Log(title = "移交记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmMoveRecord cmMoveRecord)
    {
        return toAjax(cmMoveRecordService.updateCmMoveRecord(cmMoveRecord));
    }

    /**
     * 删除移交记录
     */
    @PreAuthorize("@ss.hasPermi('caseManagement:record:remove')")
    @Log(title = "移交记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cmMoveRecordService.deleteCmMoveRecordByIds(ids));
    }
}
